//
// Created by 123 on 2025/1/10.
//
#include "vector"
#include "iostream"
#include "algorithm"
#include "string"

void test1(){
    std::vector<int> v1;
    for (int i = 0; i < 10; ++i) {
        v1.push_back(i);
    }
    //查找5是否存在
    std::vector<int>::iterator it = std::find(v1.begin(),v1.end(),5);
    if(it == v1.end()){
        std::cout << "can not find " << std::endl;

    }else{
        std::cout << "got it = " << *it << std::endl;
    }
}

class Person{
public:
    std::string name;
    int age;
public:
    Person(std::string name,int age){
        this->name = name;
        this->age = age;
    }
    //重载==
    bool operator==(const Person& p){
        if(this->name == p.name && this->age == p.age){
            return true;
        }
        return false;
    }
};

void test2(){
    std::vector<Person> v;
    Person p1("zs",11);
    Person p2("ww",22);
    Person p3("zl",33);
    v.push_back(p1);
    v.push_back(p2);
    v.push_back(p3);

    std::vector<Person>::iterator it =  std::find(v.begin(),v.end(),p2);
    if(it == v.end()){
        std::cout << "not find this person" << std::endl;
    }else{
        std::cout << "got it , name=" << it->name << " age=" << it->age << std::endl;
    }

}

int main152(){
    test1();
    test2();
}